<!DOCTYPE html>
<html>
<script src="../resources/js-test.js"></script>
<body>
<div id="embedOwner">
<embed id="embedElem" type="application/x-blink-test-plugin" width=100 height=100></embed>
<object id="objectElem" type="application/x-blink-test-plugin" width=100 height=100 tabIndex=1></object>

<embed id="embedElemWithFallbackContents"
type="application/x-blink-test-plugin" width=100 height=100 tabIndex=-1>Fallback contents.</embed>
<object id="objectElemWithFallbackContents" type="application/x-blink-test-plugin" width=100 height=100>Fallback contents.</object>

<embed id="noPluginEmbedElem" type="application/x-no-such-plugin" width=100 height=100 tabIndex=1></embed>
<object id="noPluginObjectElem" type="application/x-no-such-plugin" width=100 height=100></object>

<embed id="noPluginEmbedElemWithFallbackContents"
type="application/x-no-such-plugin" width=100 height=100 tabIndex=0>Fallback contents.</embed>
<object id="noPluginObjectElemWithFallbackContents" type="application/x-no-such-plugin" width=100 height=100>Fallback contents.</object>

<embed id="noPluginEmbedElemWithDisplayNone" type="application/x-no-such-plugin" width=100 height=100 tabindex=-1 style="display:none"></embed>
<object id="noPluginObjectElemWithDisplayNone" type="application/x-no-such-plugin" width=100 height=100 style="display:none"></object>

<embed id="noPluginEmbedElemWithContenteditable"
type="application/x-no-such-plugin" width=100 height=100 contenteditable></embed>
<object id="noPluginObjectElemWithContenteditable"
type="application/x-no-such-plugin" width=100 height=100 tabindex=-1 contenteditable></object>
</div>

<script>
description('Test for the tabIndex of embedded plugins. Plugins may be focusable so their tabIndex should be 0 by default.');

var owner = document.getElementById("embedOwner");
for (var i = 0; i < owner.childNodes.length; ++i) {
    pluginElement = owner.childNodes[i];
    if (pluginElement.id) {
        tabIndexAttribute = pluginElement.getAttribute("tabindex");
        expectedTabIndex = tabIndexAttribute ?
            tabIndexAttribute :
            pluginElement.tagName === 'EMBED' ? '-1' : '0';
        shouldBe('"' + pluginElement.id + '"; pluginElement.tabIndex', expectedTabIndex);
    }
}
</script>
</body>
</html>
